import geom.Vector;

import java.util.ArrayList;
import java.util.Iterator;

import processing.candy.SVG;
import processing.core.PApplet;


public class TreeGrow extends PApplet{
	static public void main(String args[]) {
		PApplet.main(new String[] { 

			"--present",
			"TreeGrow" 
		});
	}
	ArrayList<SimpleBranch> branches;
	public void setup(){
		size(1440, 900);
		smooth();
		frameRate(50);
		background(255);
		branches = new ArrayList<SimpleBranch>();
	}
	
	public void draw(){
		background(255);
		stroke(10);
		strokeWeight(2);
		noFill();
		Iterator<SimpleBranch> it = branches.iterator();
		while(it.hasNext()){
			SimpleBranch b = it.next();
			b.grow();
			b.draw(this);
		}
		
	}
	
	public void keyPressed(){
		if(key == 'c'){
			float x = random(1440);
			float y = random(120);
			branches.add(new SimpleBranch(new Vector(x, 900), new Vector(x, 900 - y)));
		}
	}
}
